<?php
namespace Home\Controller;
use Think\Controller;
class PostController extends PublicController {
    /*帖子列表  开发人：周弈男*/
    public function postlist(){
    	$post = M('post');
    	$post = $post->select();
    	$this->assign("post",$post);
    	$this->display();
    }

     /*评论列表  开发人：张森*/
    public function comment(){
    	$post=$_GET['postid'];
    	$comment = M('comment');
    	$comment = $comment->where("postid=$post")->select();
    	// var_dump($comment);
    	// die;
    	$this->assign("comment",$comment);
    	$this->display();
    }


      /*删除帖子  开发人：张森*/
    public function deletepost(){
        $id=$_GET['postid'];
        $post=M('post');
        // $pic=$comment->where("commentid=$id")->find();
        // unlink(realpath("./Public/photo/".$pic["pic"]));
        $post=$post->where("postid=$id")->delete();
        if($post=1){
            $this -> success('删除成功！','');
        }else{
            $this->error('删除失败！','');
        }
    }



    /*删除评论  开发人：张森*/
    public function delete(){
        $id=$_GET['commentid'];
        $comment=M('comment');
        // $pic=$comment->where("commentid=$id")->find();
        // unlink(realpath("./Public/photo/".$pic["pic"]));
        $comment=$comment->where("commentid=$id")->delete();
        if($comment=1){
            $this -> success('删除成功！','');
        }else{
            $this->error('删除失败！','');
        }
    }

}
